<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript" src="js/components/core-min.js"></script>
    <script type="text/javascript" src="js/components/cipher-core-min.js"></script>
    <script type="text/javascript" src="js/components/mode-ecb-min.js"></script>
    <script type="text/javascript" src="js/components/lib-typedarrays.js"></script>
    <script type="text/javascript" src="js/components/aes-min.js"></script>
    <script type="text/javascript" src="js/aes.js"></script>
	
	<script type="text/javascript">
		function encrypt(word) {
			//var key = CryptoJS.enc.Utf8.parse("abcdefgabcdefg12");
			var key = CryptoJS.enc.Utf8.parse("2s58d5a65s235s");
			var srcs = CryptoJS.enc.Utf8.parse(word);
			var encrypted = CryptoJS.AES.encrypt(srcs, key, {
				mode: CryptoJS.mode.ECB,
				padding: CryptoJS.pad.Pkcs7
			});
			return encrypted.toString();
		}
		function decrypt(word){
		    var key = CryptoJS.enc.Utf8.parse("2s58d5a65s235s");
		    var decrypt = CryptoJS.AES.decrypt(word, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
		    return CryptoJS.enc.Utf8.stringify(decrypt).toString();
		}
		var mingwen = {"AppID":1400079941,"UserID":"webim_test_userid"};
		var mingwen_str = JSON.stringify(mingwen);
		var jiamihou = encrypt(mingwen_str);
		console.log("加密后",jiamihou);
		$.ajax({
			type:"post",
			url:"https://lobbyserver.game.luckycatgame.com/tls_sig/service/Sign.php",
			async:true,
			data:jiamihou,
			success:function(data){
				console.log(data);
			}
		});
		console.log("解密",decrypt(jiamihou));
	</script>

</html>